
import constant from '@/utils/constant';
import common,{call} from '@/api/taskManager/common'
/* 获取查詢条件分支机构 */
export function getCompanylist(){
	let companyList =window.sessionStorage.getItem('taskmanagerCompanyList');
	if (companyList) {
		let list = JSON.parse(companyList);
		return new Promise(function (reslove, reject) {
	        reslove(list) ; //状态由等待变为成功，传的参数作为then函数中成功函数的实参
	    });
	} else {
		return call(common.apis.queryCompanylist).then(function(result) {
			window.sessionStorage.setItem('taskmanagerCompanyList',JSON.stringify(result.data))
			return new Promise(function (reslove, reject) {
		        reslove(result.data) ; //状态由等待变为成功，传的参数作为then函数中成功函数的实参
			});
		}).catch( err =>{
			
		});
	}
}

export function isSearchParamsEmpty(searchParams){
	return searchParams.caseno ==""&& searchParams.level ==""&&searchParams.begintime==""&&searchParams.lasttime==""
		&&searchParams.appbgntime==""&&searchParams.appendtime==""&& searchParams.tskbgntime==""&&searchParams.insured==""
		&&searchParams.policyer==""&& searchParams.orgId==""&&searchParams.insmain==""&&searchParams.taskstatus==""
		&& searchParams.depotno==""&& searchParams.historyHandler==""&& searchParams.appFrom ==""&& searchParams.checkoutid=="";
}
export function isSearchParamsEmpty2(searchParams){
	let isEmpty = true;
	for (let item in searchParams) {
		if (searchParams[item] !=null&&searchParams[item] !=undefined &&searchParams[item] !=''){
			isEmpty = false;
			break;
		}
	}
	return isEmpty;
}
/* 获取对应业务类型所有节点List */
export function queryNodes(){
	if (window.sessionStorage.getItem("queryNodesByBusiness")) {
	    let obj = JSON.parse(window.sessionStorage.getItem("queryNodesByBusiness"));
	    return new Promise(function (reslove, reject) {
	        reslove(obj)  //状态由等待变为成功，传的参数作为then函数中成功函数的实参
	    });
	} else {
	    return call(common.apis['queryNode']).then(res => {
	        if (res.resultCode == constant.SUCCESS && res.data) {
	            window.sessionStorage.setItem("queryNodesByBusiness", JSON.stringify(res.data));
	            return new Promise(function (reslove, reject) {
	        reslove(res.data) ; //状态由等待变为成功，传的参数作为then函数中成功函数的实参
	    });
	        }
	    }).catch(err => {
	
	    })
	}
}